﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package Classes {
    import Engine.Classes.*;
    import Engine.Interfaces.*;
    import flash.display.*;
    import flash.geom.*;

    public class CompositeItemImage extends MovieClip implements IDynamicDisplayObject {

        private var m_dirtyRect:Rectangle;

        public function CompositeItemImage(){
            this.m_dirtyRect = new Rectangle();
            super();
        }
        public function onUpdate(_arg1:Number):void{
            var _local3:IDynamicDisplayObject;
            var _local2:int;
            while (_local2 < this.numChildren) {
                _local3 = (this.getChildAt(_local2) as IDynamicDisplayObject);
                if (_local3){
                    _local3.onUpdate(_arg1);
                };
                _local2++;
            };
        }
        public function getDirtyRect():Rectangle{
            var _local1:Rectangle;
            var _local2:int;
            var _local3:DisplayObject;
            var _local4:AnimatedBitmap;
            if ((((this.m_dirtyRect.width == 0)) && ((this.m_dirtyRect.height == 0)))){
                _local2 = 0;
                while (_local2 < this.numChildren) {
                    _local3 = this.getChildAt(_local2);
                    _local4 = (_local3 as AnimatedBitmap);
                    if (_local4){
                        _local1 = _local4.targetBitmapData.rect.clone();
                        _local1.x = _local4.x;
                        _local1.y = _local4.y;
                        this.m_dirtyRect = _local1.union(this.m_dirtyRect);
                    };
                    _local2++;
                };
            };
            return (this.m_dirtyRect.clone());
        }
        public function getBaseImage():DisplayObject{
            var _local1:DisplayObject;
            if (numChildren){
                _local1 = getChildByName("base");
                if (!_local1){
                    _local1 = getChildAt(0);
                };
            };
            return (_local1);
        }
        public function getBuildingImageByType(_arg1:String):DisplayObject{
            var _local2:DisplayObject;
            if (numChildren){
                _local2 = getChildByName(_arg1);
                if (!_local2){
                    _local2 = getChildAt(0);
                };
            };
            return (_local2);
        }
        public function renderCiToBuffer(_arg1:RenderContext, _arg2:Number, _arg3:Number, _arg4:Point, _arg5:Point, _arg6:Number):void{
            var _local10:DisplayObject;
            var _local11:AnimatedBitmap;
            var _local7:int = this.numChildren;
            var _local8:Point = new Point();
            var _local9:int;
            while (_local9 < this.numChildren) {
                _local10 = this.getChildAt(_local9);
                _local11 = (_local10 as AnimatedBitmap);
                if (_local11){
                    _local8.x = _arg5.x;
                    _local8.y = _arg5.y;
                    _local8.x = (_local8.x + (_arg2 * _local11.x));
                    _local8.y = (_local8.y + (_arg3 * _local11.y));
                    if (_arg6 > 0.2){
                        if (_arg1.alphaBuffer){
                            _arg1.targetBuffer.copyPixels(_local11.targetBitmapData, _local11.targetBitmapData.rect, _local8, _arg1.alphaBuffer, _local8, false);
                        } else {
                            _arg1.targetBuffer.copyPixels(_local11.targetBitmapData, _local11.targetBitmapData.rect, _local8);
                        };
                    };
                } else {
                    if ((_local10 is Bitmap)){
                    };
                };
                _local9++;
            };
        }
        public function renderCiToBufferOld(_arg1:BitmapData, _arg2:BitmapData, _arg3:Matrix, _arg4:Number):void{
            var _local8:DisplayObject;
            var _local9:AnimatedBitmap;
            var _local10:Point;
            var _local11:ColorTransform;
            var _local12:Bitmap;
            var _local13:Point;
            var _local14:ColorTransform;
            var _local5:int = this.numChildren;
            var _local6:Matrix = new Matrix();
            var _local7:int;
            while (_local7 < this.numChildren) {
                _local8 = this.getChildAt(_local7);
                _local9 = (_local8 as AnimatedBitmap);
                _local6 = _arg3;
                if (_local9){
                    _local6.tx = (_local6.tx + (_local6.a * _local9.x));
                    _local6.ty = (_local6.ty + (_local6.d * _local9.y));
                    if (_arg2){
                        _local10 = new Point(_local6.tx, _local6.ty);
                        _arg1.copyPixels(_local9.targetBitmapData, _local9.targetBitmapData.rect, _local10, _arg2, _local10, false);
                    } else {
                        if (_arg4 < 1){
                            _local11 = new ColorTransform();
                            _local11.alphaMultiplier = _arg4;
                            _arg1.draw(_local9.targetBitmapData, _local6, _local11);
                        } else {
                            _arg1.draw(_local9.targetBitmapData, _local6);
                        };
                    };
                } else {
                    if ((_local8 is Bitmap)){
                        _local6.tx = (_local6.tx + (_local6.a * _local8.x));
                        _local6.ty = (_local6.ty + (_local6.d * _local8.y));
                        _local12 = (_local8 as Bitmap);
                        if (_arg2){
                            _local13 = new Point(_local6.tx, _local6.ty);
                            _arg1.copyPixels(_local12.bitmapData, _local12.bitmapData.rect, _local13, _arg2, _local13, false);
                        } else {
                            if (_arg4 < 1){
                                _local14 = new ColorTransform();
                                _local14.alphaMultiplier = _arg4;
                                _arg1.draw(_local12.bitmapData, _local6, _local14);
                            } else {
                                _arg1.draw(_local12.bitmapData, _local6);
                            };
                        };
                    };
                };
                _local7++;
            };
        }

    }
}//package Classes 
